package kvoog.arkanoid.rendering;

import com.artemis.systems.VoidEntitySystem;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class BackgroundRenderingSystem extends VoidEntitySystem {

	private SpriteBatch spriteBatch;
	private OrthographicCamera camera;
	private Texture backTexture;

	public BackgroundRenderingSystem(SpriteBatch spriteBatch) {
		this.spriteBatch = spriteBatch;
				
	}
	
	@Override
	protected void initialize() {
		super.initialize();
		
		backTexture = new Texture(Gdx.files.internal("sprites/skyback.png"));
		
		camera = new OrthographicCamera(8, 4.8f);
		camera.translate(4, 2.4f);
		camera.update();
	}

	@Override
	protected void processSystem() {
		spriteBatch.setProjectionMatrix(camera.combined);
		spriteBatch.disableBlending();
		spriteBatch.begin();
		
		spriteBatch.draw(backTexture, 0, 0, 8, 4.8f, 0, 0, 800, 480, false, false);
		
		spriteBatch.end();
	}

}
